/*
package com.c611.smartclassroom.annotation.aspect;

import com.alibaba.druid.support.json.JSONUtils;
import com.alibaba.fastjson.JSON;
import com.c611.smartclassroom.annotation.MyResult;
import com.c611.smartclassroom.common.DataGridView;
import com.c611.smartclassroom.model.Log;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.MethodParameter;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.NativeWebRequest;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.method.support.HandlerMethodReturnValueHandler;
import org.springframework.web.method.support.ModelAndViewContainer;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.lang.reflect.Method;
import java.util.Date;
import java.util.List;

//@Aspect
//@Component
public class MyResultAspect implements HandlerMethodReturnValueHandler {

*/
/*    @Pointcut("@annotation(com.c611.smartclassroom.annotation.MyResult)")
    public void annotationPointcut() {

    }

    @AfterReturning(value = "annotationPointcut()", returning = "rtv")
    public Object after(JoinPoint point, List rtv) {
        for (Object o : rtv) {
            System.out.println(o);
        }
//        DataGridView view = new DataGridView(200,"xxx",0l,rtv);
        return "======================";
    }*//*


    @Override
    public boolean supportsReturnType(MethodParameter returnType) {
        System.out.println("===========sdfdsf==============="+ returnType.getMethodAnnotation(MyResult.class));
        boolean hasJSONAnno = returnType.getMethodAnnotation(MyResult.class) != null || returnType.getMethodAnnotation(MyResult.class) != null;
        return hasJSONAnno;
    }

    @Override
    public void handleReturnValue(Object o, MethodParameter methodParameter, ModelAndViewContainer modelAndViewContainer, NativeWebRequest nativeWebRequest) throws Exception {
        modelAndViewContainer.setRequestHandled(true);
        MyResult res=methodParameter.getMethodAnnotation(MyResult.class);
        String type = res.type();
        HttpServletResponse response=nativeWebRequest.getNativeResponse(HttpServletResponse.class);
        response.setContentType(MediaType.APPLICATION_JSON_UTF8_VALUE);
        PrintWriter writer = null;
        DataGridView info = new DataGridView(200,"",0L,(List) o);
        try {
            writer = response.getWriter();
            writer.write(JSON.toJSONString(info));
            writer.flush();
        } catch (IOException ex) {
            ex.printStackTrace();
        } finally {
            if (writer != null)
                writer.close();
        }
    }
}
*/
